// pages/moneyback/moneyback.js
const app = getApp()
Page({

  data: {
    total:'',
    content:'',
    reason:'',
    amount:'',
    listdel: '',
    items: [
      { name: '需要修改定制图片或文案，需要重新下单', value: '1.需要修改定制图片或文案，需要重新下单' },
      { name: '审核未通过不愿意修改定制内容', value: '2.审核未通过不愿意修改定制内容'},
      { name: '收货信息填写错误', value: '3.收货信息填写错误' },
      { name: '其他', value: '4.其他' },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      amount: options.amount,
      total: options.total
    })
    this.getdel(options.oid, options.uvid)
  },
  getdel(oid, uvid) {  //订单列表
    let that = this;
    wx.request({   //传后台
      url: app.globalData.url + '/jxb/order/getOrderInfo',
      method: 'GET',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        oid: oid,
        token: wx.getStorageSync('token'),
        uvid: uvid,
      },
      success: function (res) {
        that.setData({
          listdel: res.data.data.orderInfo,
          
        })

      },

    })
  },
 
  radioChange: function (e) { //选择原因
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    this.setData({
      reason: e.detail.value
    })
  },
  contentinp(e) {  //获取原因
    this.setData({
      content: e.detail.value
    })
  },
  submit(){
    console.log(2)
    wx.request({   //传后台
      url: app.globalData.url + '/jxb/order/userRefund',
      method: 'GET',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        oid: this.data.listdel[0].oid,
        token: wx.getStorageSync('token'),
        reason: this.data.reason,
        amount: this.data.total,
        content: this.data.content,
      },
      success: function (res) {
        if(res.data.code==0){
          wx.showModal({
            title: '提示',
            confirmColor: '#28A8F9',
            showCancel: false,
            content: res.data.msg,
            success: function (res) {
              if (res.confirm) { 
                wx.navigateBack();
              } else if (res.cancel) {
                return;
              }
            }
          })
        }else{
          wx.showModal({
            title: '提示',
            confirmColor: '#28A8F9',
            showCancel: false,
            content: res.data.msg,
          })
        }
       

      },

    })
  }
})